package com.zipking.cloud.springbootmybatis.task;

import lombok.extern.slf4j.Slf4j;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Slf4j
@Component
public class ShedLockTask {
    //定时任务1
   // @Scheduled(cron = "*/2 * * * * ?")
   // @SchedulerLock(name = "scheduledTaskName", lockAtMostFor = "1s", lockAtLeastFor = "1s")
   // public void scheduledTask() {
        //todo 定时任务业务逻辑实现
    //    log.info("scheduledTaskName");
   // }


   // private static final String lockTime = 1000 * 5;

    //@Scheduled(cron = "0/1 * * * * ?")
    //@SchedulerLock(name = "TaskScheduler_scheduledTask", lockAtMostFor = "5s", lockAtLeastFor =  "5s")
    public void run()
    {
        System.out.print(new Date().toString() + "\n");
    }

    //定时任务2
    //@Scheduled(cron = "*/5 * * * * ?")
  /*  @SchedulerLock(name = "scheduledTaskFive", lockAtMostFor =  "4s", lockAtLeastFor = "4s")
    public void scheduledTaskFive() {
        //todo 定时任务业务逻辑实现
        log.debug("scheduledTaskName-5s");

    }*/

}
